﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SF.Base.Core;
using System.Data;
using System.Text;
using System.Text.RegularExpressions;

namespace SF.Dict.Web {
	public partial class Setting : BasePage {

		protected void Page_Load(object sender, EventArgs e) {
			UserEntity user = Global.DTUser;
			if (!Page.IsPostBack) {
				ltl_login.Text = user.Login;
				tb_account.Text = user.NiceName;

				string birthday = user.UserMeta["birthday"];

				if (!string.IsNullOrEmpty(birthday)) {
					string[] birthdays = Regex.Split(birthday, "-");

					tb_birthday_year.Text = birthdays[0];
					tb_birthday_month.Text = birthdays[1];
					tb_birthday_day.Text = birthdays[2];
				}

				if (user.UserMeta["qq"] != null) {
					tb_qq.Text = user.UserMeta["qq"];
				}
				if (user.UserMeta["msn"] != null) {
					tb_msn.Text = user.UserMeta["msn"];
				}
				if (user.UserMeta["qqweibo"] != null) {
					tb_qqweibo.Text = user.UserMeta["qqweibo"];
				}
				if (user.UserMeta["sinaweibo"] != null) {
					tb_sinaweibo.Text = user.UserMeta["sinaweibo"];
				}
				if (user.UserMeta["douban"] != null) {
					tb_douban.Text = user.UserMeta["douban"];
				}
				if (user.UserMeta["renren"] != null) {
					tb_renren.Text = user.UserMeta["renren"];
				}
				if (user.UserMeta["qzone"] != null) {
					tb_qzone.Text = user.UserMeta["qzone"];
				}
				if (user.UserMeta["intro"] != null) {
					tb_intro.Text = user.UserMeta["intro"];
				}

				string script = "$(document).ready(function () {";

				if (user.UserMeta["sex"] != null) {

					script += "$(\"input[name='sex'][value='" + user.UserMeta["sex"] + "']\").attr('checked',true);\r\n";

				}
				if (user.UserMeta["station"] != null) {
					script += "$(\"input[name='station'][value='" + user.UserMeta["station"] + "']\").attr('checked',true);";
				}

				script += "});";

				if (!ClientScript.IsClientScriptBlockRegistered("initradio")) {
					ClientScript.RegisterClientScriptBlock(Page.GetType(), "initradio", script, true);
				}
			}
		}
	}
}